<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // function hello()//无参数列表
    // {
    //     console.log("hello")
    // }
    // hello()

    // function helloname(num,name)//有参数列表
    // {
    //     console.log(num+" hello "+name)
    //     return 1;
    // }
    // let a=helloname(1,"xiaoming");
    // console.log(typeof(a));//number

    // let a=function sum()
    // {
    //     ret=0;
    //     for(i=0;i<=100;i++)
    //     {
    //         ret+=i;
    //     }
    //     return ret;
    // }
    // console.log(a());

    // let b=function()
    // {
    //     console.log(arguments)
    // }
    // b();
    // b(1,2,3);

    //创建对象
    // let a={}
    // let student=
    // {
    //     name:"藏三",
    //     height:"180",
    //     weight:"70kg",
    //     sayhello:function()
    //     {
    //         console.log("hello 藏三")
    //     }
    // }
    // console.log(student.name)
    // console.log(student["height"])
    // console.log(student['weight'])
    // student.sayhello()

    // let s1=new Object()
    // s1.name="小明"
    // s1.age=20
    // s1['weight']="75kg"
    // s1.sayhello=function()
    // {
    //     console.log("hello 小明")
    // }

    // console.log(s1);
    // s1.sayhello()

    //构造函数不需要return
    // function People(name,height,weight)
    // {
    //     this.name=name
    //     this.height=height
    //     this.weight=weight
    //     this.Say=function()
    //     {
    //         console.log(name+" say hello")
    //     }
    // }
    // let xiaoming=new People("xiaoming",12,13)
    // let xiaohong=new People("xiaohong",12,13)
    // console.log(xiaoming)
    // xiaoming.Say()
    // console.log(xiaohong)
    // xiaohong.Say()

    //后面引入了class
    class People
    {
        constructor(name,height,age)
        {
            this.name=name;
            this.height=height;
            this.age=age;
            // this.say=function()
            // {
            //     console.log(name+" is saying")
            // }
        }
        say()//class 内直接这么写
        {
            console.log(this.name+" is saying");
        }
        static other="other";//static修饰属于类，不属于对象，只能用类去调用
        static func()
        {
            return 100;
        }
    }
    let xiaoming=new People("xiaoming",12,14)
    console.log(xiaoming)
    xiaoming.say()
    console.log(People.other)
    console.log(People.func())  

    class Student extends People//继承
    {
        constructor(name,height,age,number)
        {
            super(name,height,age);
            this.number=number;
        }
        say()//重写
        {
            alert(this.name)
        }
    }
    let student=new Student("张三",180,18,1);
    console.log(student);
    student.say()








</script>
</html>